/* 弹出窗口样式 - 图片视频下载器 */

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 根变量 */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --error-color: #f44336;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-disabled: #999999;
    --background-primary: #ffffff;
    --background-secondary: #f5f5f5;
    --border-color: #e0e0e0;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* 基础样式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background-primary);
    width: 400px;
    min-height: 500px;
    max-height: 600px;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* 弹出窗口容器 */
.popup-container {
    display: flex;
    flex-direction: column;
    min-height: 500px;
    max-height: 600px;
    width: 100%;
}

/* 头部样式 */
.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-light);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.header-title h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* 按钮样式 */
.btn-icon {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--text-disabled);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--background-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-secondary:disabled {
    color: var(--text-disabled);
    cursor: not-allowed;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 8px 12px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-text:hover {
    background: rgba(33, 150, 243, 0.1);
    border-radius: var(--border-radius);
}

/* 扫描状态 */
.scan-status {
    padding: 16px 20px;
    background: var(--background-secondary);
    border-bottom: 1px solid var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.status-text {
    color: var(--text-secondary);
    font-size: 13px;
}

/* 媒体统计 */
.media-stats {
    display: flex;
    padding: 16px 20px;
    gap: 24px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-number {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 媒体容器 */
.media-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
}

.media-section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.section-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 复选框样式 */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.checkbox-container input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    position: relative;
    transition: var(--transition);
}

.checkbox-container input[type="checkbox"]:checked+.checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-container input[type="checkbox"]:checked+.checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* 媒体列表 */
.media-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.media-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.media-item:hover {
    box-shadow: var(--shadow-light);
    transform: translateY(-2px);
}

.item-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
}

.item-checkbox .checkmark {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
}

.item-preview {
    position: relative;
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: var(--background-secondary);
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.preview-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-secondary);
    color: var(--text-disabled);
}

.preview-placeholder svg {
    width: 48px;
    height: 48px;
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.media-item:hover .preview-overlay {
    opacity: 1;
}

.preview-btn {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.preview-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.item-info {
    padding: 12px;
}

.item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-details {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.item-size,
.item-format,
.item-duration {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--background-secondary);
    padding: 2px 6px;
    border-radius: 3px;
}

.item-actions {
    display: flex;
    gap: 4px;
}

.action-btn {
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 4px;
}

.action-btn:hover {
    background: var(--background-secondary);
    color: var(--primary-color);
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

/* 下载进度 */
.download-progress {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow-medium);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

.progress-header h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.progress-list {
    padding: 12px 20px;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.progress-item:last-child {
    border-bottom: none;
}

.progress-info {
    flex: 1;
    min-width: 0;
}

.progress-filename {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-status {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.progress-bar {
    width: 80px;
    height: 4px;
    background: var(--background-secondary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-actions {
    display: flex;
    gap: 4px;
}

.progress-btn {
    color: var(--text-secondary);
    padding: 4px;
}

.progress-btn:hover {
    color: var(--primary-color);
}

/* 底部操作栏 */
.popup-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: var(--background-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.popup-footer .btn-primary {
    flex: 1;
    justify-content: center;
}

/* 响应式设计 */
@media (max-width: 400px) {
    body {
        width: 100%;
    }

    .media-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .popup-footer {
        flex-direction: column;
        gap: 12px;
    }

    .popup-footer .btn-primary {
        width: 100%;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--background-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.media-item {
    animation: fadeIn 0.3s ease;
}

/* 状态样式 */
.media-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.media-item.downloading {
    border-color: var(--warning-color);
}

.media-item.completed {
    border-color: var(--success-color);
}

.media-item.error {
    border-color: var(--error-color);
}

/* 加载状态 */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    line-height: 1.4;
}